/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.testis.utils.tree;

import org.testis.orm.labelhandler.LabelRefined;
import javax.swing.tree.DefaultMutableTreeNode;

import org.testis.utils.tree.LabelTreeNode;

/**
 *
 * @author selcuk
 */
public class DefaultMutableLabelNode extends DefaultMutableTreeNode {

    public DefaultMutableLabelNode(LabelTreeNode userObject) {
        super(userObject);
        if (userObject == null) {
            throw new NullPointerException("LabelTreeNode: userObject is null");
        }
    }

    public DefaultMutableLabelNode(String str) {
        super(new LabelTreeNode(str));
    }

    public LabelRefined getLabel() {
        LabelTreeNode userObj = (LabelTreeNode) getUserObject();
        Object obj = userObj.getObject();
        if (obj != null && obj instanceof LabelRefined) {
            return (LabelRefined) obj;
        }
        return null;
    }

    public boolean isSelected() {
        LabelTreeNode obj = (LabelTreeNode) getUserObject();
        return obj.isSelected();
    }

    @Override
    public String toString() {
        LabelTreeNode obj = (LabelTreeNode) getUserObject();
        return obj.toString();
    }
}
